package com.example.grpc.service.helloworld;

import io.grpc.examples.helloworld.DubboGreeterGrpc;
import io.grpc.examples.helloworld.GreeterGrpc;
import io.grpc.examples.helloworld.HelloReply;
import io.grpc.examples.helloworld.HelloRequest;
import io.grpc.stub.StreamObserver;
import org.apache.dubbo.config.annotation.DubboService;

@DubboService(interfaceClass = DubboGreeterGrpc.IGreeter.class,loadbalance = "roundrobin", version = "1.0")
public class GreeterServiceImpl extends DubboGreeterGrpc.GreeterImplBase {

    @Override
    public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver){
        System.out.println("request name:" + request.getName());
        HelloReply reply = HelloReply.newBuilder().setMessage("Hello " + request.getName()).build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }
}
